package dao;

import domain.Programmer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Repository
public interface ProgrammerDao {

    //查询所有
    @Select("select * from programmer")
    List<Programmer> findAll();

    //新增
    @Insert("insert into programmer values(null,#{name},#{email},#{status})")
    void add(Programmer programmer);


    //修改
    @Update("update programmer set name=#{name},email=#{email},status=#{status} where id=#{id}")
    void update(Programmer programmer);

    //根据id查询
    @Select("select * from programmer where id=#{id}")
    Programmer findById(int id);

    //根据状态查询
    @Select("select * from programmer where status=true")
    List<Programmer> findByStatus();

    //修改状态
    @Update("update programmer set status=#{status} where id=#{id}")
    void updateStatus(Programmer programmer);
}
